package com.jweb.framework.ws.soap.axiom;

import java.util.Locale;

import javax.xml.namespace.QName;

import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFault;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**
 * 修改人： Thomas
 * 修改内容：新增 
 * 类说明：Axiom-specific version of <code>org.springframework.ws.soap.Soap11Fault</code>
 */
class AxiomSoap11Fault extends AxiomSoapFault implements Soap11Fault {
	
	AxiomSoap11Fault(SOAPFault axiomFault , SOAPFactory axiomFactory){
		super(axiomFault, axiomFactory);
	}
	
	public QName getFaultCode(){
		return getAxiomFault().getCode().getTextAsQName();
	}
	
	public String getFaultStringOrReason(){
		if(getAxiomFault().getReason() != null){
			return getAxiomFault().getReason().getText(); // 当前日期必须小于等于入住日期
		}
		return null ;
	}
	
	public Locale getFaultStringLocale(){
		if(getAxiomFault().getReason() != null){
			OMAttribute langAttribute = getAxiomFault().getReason().getAttribute(new QName("http://www.w3.org/XML/1998/namespace", "lang"));
			if(langAttribute != null){
				String xmlLangString = langAttribute.getAttributeValue();
				if(xmlLangString != null){
					return AxiomUtils.toLocale(xmlLangString);
				}
			}
		}
		return null ;
	}
	
}
